using System;
using System.Collections.Generic;
using System.Text;
using Bule.Malbilden.Data;

namespace Bule.Malbilden.Domain
{
    public class DayNutritionGoal : IPersistable
    {
        // SLV (~): Fat: 30E%, Carbs: 55E%, Fiber: 30 g, Protein: 15E%

        public DayNutritionGoal() { }
        public DayNutritionGoal(int kcal, int protein, int carbs, int fat, int fiber) : this(kcal, protein, carbs, fat, fiber, DateTime.Now){ }

        public DayNutritionGoal(int kcal, int protein, int carbs, int fat, int fiber, DateTime date)
        {
            Kcal = kcal;
            ProteinEnergyPercentage = protein;
            FatEnergyPercentage = fat;
            CarbohydrateEnergyPercentage = carbs;
            FiberWeight = fiber;
            Date = date;
        }

        public DayNutritionGoal(DayNutritionGoal toCopy)
        {
            this.Kcal = toCopy.Kcal;
            this.ProteinEnergyPercentage = toCopy.ProteinEnergyPercentage;
            this.FatEnergyPercentage = toCopy.FatEnergyPercentage;
            this.CarbohydrateEnergyPercentage = toCopy.CarbohydrateEnergyPercentage;
            this.FiberWeight = toCopy.FiberWeight;
            this.Date = toCopy.Date;
        }

        public virtual int Id { get; set; }
        public virtual int FiberWeight { get; set; }
        public virtual int FatEnergyPercentage { get; set; } // Energy percent
        public virtual int CarbohydrateEnergyPercentage { get; set; } // Energy percent
        public virtual int ProteinEnergyPercentage { get; set; } // Energy percent
        public virtual int Kcal { get; set; } 
        public virtual DateTime Date { get; set; }

        // override object.Equals
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
                return false;

            var right = (DayNutritionGoal)obj;

            return FiberWeight == right.FiberWeight && 
                FatEnergyPercentage == right.FatEnergyPercentage && 
                CarbohydrateEnergyPercentage == right.CarbohydrateEnergyPercentage &&
                ProteinEnergyPercentage == right.ProteinEnergyPercentage && 
                Kcal == right.Kcal && 
                Date == right.Date;
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }
    }
}
